package com.woniuxy.dao;

import com.woniuxy.entity.CarType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CarTypeMapper {
    /**
     * 传入
     * @param typeName
     */
    List<CarType> findAll(String typeName);

    /**
     * 判断是否存在
     */
    @Select("select * from car_type where type_name = #{typeName}")
    CarType findByCarType(String typeName);

    /**
     * 添加
     * @param carType
     * @return
     */
    @Insert("insert into car_type values(null,#{typeName},#{company},#{remarks})")
    int save(CarType carType);

    /**
     * 修改
     * @param carType
     * @return
     */
    @Update("UPDATE car_type set type_name=#{typeName},company=#{company},remarks=#{remarks} where id=#{id}")
    int updateById(CarType carType);
    /**
     * 删除
     */
    @Delete("delete from car_type where id=#{id}")
    int deleteById(Integer id);
    /**
     * 批量删除
     *
     */
    int deleteBatch(@Param("ids") String[] ids);

    /**
     * 批量添加数据
     */
    int insertBatch(List<CarType> carTypeList);

    /**
     * 远程查找所有类型返回下拉框
     * @param typeName
     * @return
     */
    @Select("select * from car_type where type_name like concat('%',#{typeName}, '%')")
    List<CarType> findAllCarType(String typeName);
}
